<template>
    <template v-for="(item, index) in props.menuData">
        <el-menu-item @click="selectMenu(item)"  v-if="!item.children || item.children.length == 0" :index="item.path" :key="index">
                <el-icon>
                    <component :is="item.iconV3"></component>
                </el-icon>
                <span>{{ item.name }}</span>
        </el-menu-item>

        <el-sub-menu  v-else :index="item.path" :key="index + 1">
            <template #title>
                <el-icon>
                    <component :is="item.iconV3"></component>
                </el-icon>
                <span>{{ item.name }}</span>
            </template>
            <TreeMenu :menuData="item.children" />
        </el-sub-menu>
    </template>
</template>

<script setup>
import { useStore } from "vuex";
const store = useStore();

const props = defineProps(['menuData'])
function selectMenu(val){
      store.commit('tags/SET_MENU',val)
    }
</script>
<style lang="less" scoped></style>